home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / PACKAGES / CAS.ZIP / DS.DOC < prev    next >
Text File  |  1996-11-06  |  11KB  |  260 lines

  1.                       OBJECT FILE FORMAT, and
  2.                       OBJECT FILE DiSPLAY UTILITY
  3.  
  4. (0) COMMAND LINE, INPUT FORMAT
  5.    This utility will display the contents of an object file created by the
  6. assembler.  The command line is typically of the form:
  7.  
  8.                      ds file.o >file.x
  9.  
  10. The contents of an object file are as follows:
  11.  
  12.    HEADER, IMAGE, FILES, SEGMENTS, GAPS, SYMBOLS, EXPRESSIONS, RELOCATIONS
  13.  
  14.    (a) HEADER
  15.       Bytes   Item
  16.         2     55aa ... the MAGIC number
  17.         4     Location of first item past the end of the memory IMAGE.
  18.         4     Number of FILES listed.
  19.         4     Number of SEGMENTS listed.
  20.         4     Number of GAPS listed.
  21.         4     Number of SYMBOLS listed.
  22.         4     Number of unresolved EXPRESSIONS listed.
  23.         4     Number of RELOCATION items listed.
  24.         4     Check sum of the previous 7 items.
  25.  
  26.    (b) IMAGE
  27.    This is a binary listing of each of the code segments contained in
  28. this object file, all concatentated together.  This binary format is listed
  29. by the display program 16 bytes per line, each byte written in hexadecimal
  30. form.  It is also displayed in character form to the right-hand side, in order
  31. to show off any embedded strings.
  32.  
  33.    The size of the image is given in two ways: (a) it is the sum of the sizes
  34. of all the code segments listed minus all the sizes of all the gaps listed, and
  35. (b) it is the number of bytes contained between the end of the header and the
  36. end of the image (which is indicated in the header).
  37.  
  38.    (c) FILES
  39.    Source and header file names are added to the object file as needed to help
  40. the linker determine where any errors may be originating from.  Each file is
  41. listed in the following form:
  42.  
  43.                   Bytes          Item
  44.                     1            L = length of file name
  45.                     L            file name
  46.  
  47.    (d) SEGMENTS
  48.    The segments 0 through 4 are only used internally by the assembler.  They
  49. have the types respectively code, xdata, data, sfr, and bit.  Their sizes are
  50. 0, bases are 0, and they are absolute.  These segments serve as default
  51. segments for absolute addresses.
  52.    The remaining segments (if there are any) are listed in the following
  53. format:
  54.                 ## Line File Rel Type Base Size  Loc
  55.  
  56. which indicate, respectively, the segment's number, the line and file where it
  57. is first defined, whether it is relative, the segment's type (0 = code,
  58. 1 = xdata, 2 = data, 3 = sfr, and 4 = bit, 3 and 4 are never seen).  The Base
  59. is 0 for relative segments, else it points to the actual starting address of the
  60. segment.  The Size is the number of bytes in the segment, and (for code
  61. segments) Loc is the place in the object file where its image is found.
  62.    Each segment is formatted in the object file as follows:
  63.  
  64.                   Bytes          Item
  65.                     2            Line
  66.                     2            File
  67.                     2            Bits 0-7 = Type
  68.                                  Bit 8 = 1 for relative segments, 0 else.
  69.                     2            Size
  70.                     2            Base
  71.                     4            Loc
  72.  
  73. The file number indicated indexes the appropriate entry in the file list
  74. previously described.
  75.  
  76.    (d) GAPS
  77.    Gaps are subsets of segments that are reserved but that have no
  78. corresponding memory image.  No memory output is generated for gaps.
  79. They are displayed in the following format:
  80.  
  81.                         ##  Seg  Off Size
  82.  
  83. where Seg, and Off are the segment where the gap occurs and its offset
  84. within the segment.  Size is the size of the gap.
  85.    Two constraints will apply for valid object files: (1) every gap will
  86. be located entirely within its segment (Off + Size < segment's size), and
  87. (2) only code segments contain gaps.
  88.    Each gap is formatted in the object file as follows:
  89.  
  90.                   Bytes          Item
  91.                     2            Segment index
  92.                     2            Offset
  93.                     2            Size
  94.  
  95.    (e) SYMBOLS
  96.    Each symbol is displayed in the following format:
  97.              ##     Scope Var Type   Value  Name
  98.  
  99. where ## is the symbol's index, Scope is defined in terms of the GLOBAL
  100. and DEFINED attributes as follows:
  101.  
  102.                Scope           GLOBAL    DEFINED
  103.                undefined
  104.                local                        x
  105.                external          x
  106.                global            x          x
  107.  
  108. Var is marked if the symbol is a variable.  Variables and global/externals
  109. are disjoint.  Its type and value will be displayed as one of the following:
  110.  
  111.                       ADDR  Seg   Offset
  112.                       NUM   Value
  113.  
  114. The first case indicates a symbol defined as an address.  Its segment index
  115. and offset are then listed.  The second case indicates numeric value.  The
  116. actual value is then listed.  Offset and Value are listed in hexadecimal
  117. format.  Neither the Offset nor Value are applicable if the symvol is not
  118. defined (external or undefined).  Seg is inapplicable if the symbol is
  119. totally undefined.
  120.    Following this is the symbol's name.
  121.  
  122.    Each symbol is formatted in the object file as follows:
  123.  
  124.                   Bytes          Item
  125.                     1            Bit 0: 1 if variable, 0 if constant
  126.                                  Bit 1: 1 if address, 0 if numeric
  127.                                  Bit 2: DEFINED
  128.                                  Bit 3: GLOBAL
  129.                     2            Segment index
  130.                     2            Offset/Value
  131.                     2            L = Length of symbol name
  132.                     L            Symbol name
  133.  
  134.    (f) EXPRESSIONS
  135.    These items represent expressions that could not be evaluated from the
  136. information presented in the source files.  Expression evaluation is deferred
  137. to the linker if the expression contains relative addresses, or externally
  138. defined symbols.
  139.  
  140.    They are displayed as follows:
  141.                      ## Line File  Tag Args...
  142.  
  143. where the first 3 items are respectively the epxressions's index, and the line
  144. and file where it is defined.  Tag and args will take on one of the sets of
  145. values:
  146.  
  147.              Descriuption      Tag  Args
  148.              Number             0   Value
  149.              Address            1   Seg           Offset
  150.              Symbol             2   Symbol Name
  151.              Unary operation    3   Unary         A
  152.              Binary operation   4   Binary        A        B
  153.              Conditional        5   A             B        C
  154.  
  155. where A, B, and C are indexes of previously defined expression occurring earlier
  156. in the list, Symbol Name is the name of the symbol which the expression is set
  157. to, Seg and Offset are the segment and offset of an address expression, Value
  158. is the numeric value of a numeric expression, and Binary and Unary are
  159. symbolic number for operators defiend as follows:
  160.  
  161.                             Unary Operators
  162.                            Operator   Value
  163.                               ~         27
  164.                               !         28
  165.                              high       29
  166.                              low        30
  167.                               +         31
  168.                               -         32
  169.  
  170.                            Binary Operators
  171.                            Operator   Value
  172.                               +         31
  173.                               -         32
  174.                               *         33
  175.                               /         34
  176.                               %         35
  177.                               <         36
  178.                               <=        37
  179.                               >         38
  180.                               >=        39
  181.                               ==        40
  182.                               !=        41
  183.                               &&        42
  184.                               ||        43
  185.                               &         44
  186.                               ^         45
  187.                               |         46
  188.                               <<        47
  189.                               >>        48
  190.                               .         49
  191.                               by        50
  192.  
  193.    The format of an expression in the object file is as follows:
  194.                   Bytes          Item
  195.                     2            Line
  196.                     2            File
  197.                     1            Tag
  198.  
  199. with the following cases:
  200.             (i) Numeric (Tag = 0)                     Number
  201.                   Bytes          Item
  202.                     2            Value
  203.             (i) Address (Tag = 1)                     Segment:Offset
  204.                   Bytes          Item
  205.                     2            Segment Index
  206.                     2            Offset
  207.             (i) Symbol (Tag = 2)                      Symbol
  208.                   Bytes          Item
  209.                     2            Symbol Index
  210.             (i) Unary operation (Tag = 3)             Op A
  211.                   Bytes          Item
  212.                     1            Operator
  213.                     2            Expression A's index.
  214.             (i) Binary operation (Tag = 4)            A Op B
  215.                   Bytes          Item
  216.                     1            Operator
  217.                     2            Expression A's index.
  218.                     2            Expression B's index.
  219.             (i) Conditional operation (Tag = 5)       A? B: C
  220.                   Bytes          Item
  221.                     2            Expression A's index.
  222.                     2            Expression B's index.
  223.                     2            Expression C's index.
  224.                    
  225.    (g) RELOCATIONS
  226.    A relocation item indicates an unevaluated expression, some information about
  227. its addressing mode, and the segment and offset where it is to be patched.
  228. These are items that the assembler could not properly determine because external
  229. references were used or relative addressing was used.  All relocations refer to
  230. positions within code segments, since only code segments have memory images.
  231.  
  232.    A relocation item is displayed as follows:
  233.  
  234.               Line File Tag  Exp  Seg: Off
  235.  
  236. where Line and File determine the corresponding point in the source file, Seg
  237. and Off refer to the location where the patch is to be applied, Exp is the item
  238. to be patched, and Tag is the type of reliocation defined as follows:
  239.  
  240.                       Tag       Description
  241.                        b        Byte-sized constant
  242.                        w        Word-sized constant
  243.                        B        Bit address
  244.                        D        Direct register address
  245.                                    Data address < 80h
  246.                                 or SFR address >= 80h.
  247.                        R        Relative code address
  248.                        P, Q     Paged code address.
  249.                        L        Absolute (long) code address.
  250.  
  251.    Relocation items are formatted in the object file as follows:
  252.  
  253.                   Bytes          Item
  254.                     2            Line
  255.                     2            File
  256.                     1            Tag
  257.                     2            Expression index
  258.                     2            Segment index
  259.                     2            Offset
  260.